﻿@using System.Web.Mvc
@using System.Web.Mvc.Ajax
@using System.Web.Mvc.Html
@using nanoCMS.Forum.Resources
@using nanoCMS.Forum.WebUI.Models.ViewModels
@model EditPostVM 


<div id="edit_form">
    @using (Ajax.BeginForm("SavePost", "Forum", new { area = "Forum" }, 
        new AjaxOptions { UpdateTargetId = "validationSummary", OnComplete = "SavePostComplete" }, new { }))
    {
        <div id="validationSummary">
        </div>
        <input type="hidden" name="ThreadID" id="EditPostVM_Thread_ThreadID" value="@(Model.Thread.ThreadID)"/>
        <input type="hidden" name="PostID" id="EditPostVM_Post_PostID" value="@(Model.Post.PostID)"/>
                <input type="hidden" name="link" value="@ViewContext.RequestContext.RouteData.Values["link"]"/>
        <input type="hidden" name="elementKey" value="@ViewBag.ElementKey"/>
        <fieldset id="">
            <legend>@Translation.CreatePost</legend>
            <div>
                <label for="EditPostVM_Post_Title">
                    @Translation.Title:</label>
                <input type="text" name="Title" id="EditPostVM_Post_Title" 
                    value="@Model.Post.Title"/>
            </div>
            <div>
                <div>
                    <label for="EditPostVM_Post_Content">
                        @Translation.PostContent</label>
                    <textarea rows="10" cols="50" name="Content" id="EditPostVM_Post_Content">@Model.Post.Content</textarea>
                </div>
            </div>
            <div>
                <input type="submit" value="@Translation.Save" />
            </div>
        </fieldset>
    }
</div>
<script type="text/javascript">
    function SavePostComplete(params) {
        ajaxFormSuccess(jQuery.parseJSON(params.responseText));
    }
</script>

